j3deditor.bin.hierarchy
Class J3DeObject

java.lang.Object
  extended by j3deditor.bin.hierarchy.HierarchyNode
      extended by j3deditor.bin.hierarchy.J3DeObject
All Implemented Interfaces:
Copyable, Cuttable, Deletable
Direct Known Subclasses:
J3DeLight, J3DePrimitive, J3DeShape3D, J3DeTextureAttributes

public class J3DeObject
extends HierarchyNode
implements Copyable, Cuttable, Deletable

Base class for transformable objects. Contains an instance of javax.media.j3d.TransformGroup and javax.media.j3d.Node attached to it

Author:
Risto Seene
See Also:
TransformGroup

Constructor Summary
J3DeObject(java.lang.String name, HNodeType type, long numOfNodes)
          Creates an instance of J3DeObject with the given name, type and index.
 
Method Summary
protected  HierarchyNode clone(HierarchyNode node)
          Clones this node.
 void delete()
          Removes this node from its parent.
protected  javax.media.j3d.Node get3DObject()
          Returns the Java 3D Node attached to this nodes TransformGroup.
 javax.media.j3d.TransformGroup getObject()
          Returns the TransformGroup object of this node.
 float getRotationZ()
          Returns the rotation around Z-axis.
 float getRotationX()
          Returns the rotation around X-axis.
 float getRotationY()
          Returns the rotation around Y-axis.
 float getScaleZ()
          Returns the scale on Z-axis.
 float getScaleX()
          Returns the scale on X-axis.
 float getScaleY()
          Returns the scale on Y-axis.
 float getTranslationZ()
          Returns the position on Z-axis.
 float getTranslationX()
          Returns the position on X-axis.
 float getTranslationY()
          Returns the position on Y-axis.
 void initObject(javax.media.j3d.Node object)
          Attaches the given Java 3D object to the TransformGroup inside this node.
 void rotate(float x, float y, float z)
          Sets the given absolute angle on each axis.
 void rotateZ(float angle, boolean isLocal)
          Rotates the object around the Z-axis.
 void rotateX(float angle, boolean isLocal)
          Rotates the object around the X-axis.
 void rotateY(float angle, boolean isLocal)
          Rotates the object around the Y-axis.
 void scale(float x, float y, float z)
          Sets the given absolute scale on each axis.
 void scaleAll(float difference)
          Resizes this object on all axes.
 void scaleZ(float difference, boolean isLocal)
          Resizes this object on Z-axis.
 void scaleX(float difference, boolean isLocal)
          Resizes this object on X-axis.
 void scaleY(float difference, boolean isLocal)
          Resizes this object on Y-axis.
protected  void setNode(javax.media.j3d.Node node)
          Replaces the TransformGroup object of this node with the given object and sets its capabilities.
 void setObject(javax.media.j3d.TransformGroup transform)
          Copies the transformation from the given TransformGroup object to the TransformGroup object of this node.
 void translate(float x, float y, float z)
          Sets the given absolute translation on each axis.
 void translateZ(float z, boolean isLocal)
          Moves the object along the Z-axis.
 void translateX(float x, boolean isLocal)
          Moves the object along the X-axis.
 void translateY(float y, boolean isLocal)
          Moves the object along the Y-axis.
 
Methods inherited from class j3deditor.bin.hierarchy.HierarchyNode
equals, getChild, getIndex, getIndexOfChild, getNumberOfChildren, getParent, getParent, getType, hasNamedChild, removeChild, setName, setParent, toString, updateName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

J3DeObject

public J3DeObject(java.lang.String name,
                  HNodeType type,
                  long numOfNodes)
Creates an instance of J3DeObject with the given name, type and index.

Parameters:
name - the name of this object
type - the type of this object
numOfNodes - the index of this object
Method Detail

initObject

public void initObject(javax.media.j3d.Node object)
Attaches the given Java 3D object to the TransformGroup inside this node.

Parameters:
object - object to be attached to

getObject

public javax.media.j3d.TransformGroup getObject()
Returns the TransformGroup object of this node.

Returns:
Returns the TransformGroup object of this node

get3DObject

protected javax.media.j3d.Node get3DObject()
Returns the Java 3D Node attached to this nodes TransformGroup.

Returns:
Returns Java 3D Node object contained in this node

setObject

public void setObject(javax.media.j3d.TransformGroup transform)
Copies the transformation from the given TransformGroup object to the TransformGroup object of this node.

Parameters:
transform - transformation object the transformation will be copied from

setNode

protected void setNode(javax.media.j3d.Node node)
                throws java.lang.Exception
Replaces the TransformGroup object of this node with the given object and sets its capabilities.

Parameters:
node - new TransformGroup object
Throws:
java.lang.Exception - if the given node is not an instance of TransformGroup or it does not have any children

clone

protected HierarchyNode clone(HierarchyNode node)
Clones this node. Should only be called by subclasses

Overrides:
clone in class HierarchyNode
Parameters:
node - node sent by subclass
Returns:
the same node that was inserted

delete

public void delete()
            throws java.lang.Exception
Removes this node from its parent.

Specified by:
delete in interface Deletable
Throws:
java.lang.Exception - if cannot remove the TransformGroup object of this node from its parent or this node has no parent

translateX

public void translateX(float x,
                       boolean isLocal)
Moves the object along the X-axis.

Parameters:
x - specifies how much this object will be moved
isLocal - specifies whether the object is moved along its local axes or along the axes of scene

translateY

public void translateY(float y,
                       boolean isLocal)
Moves the object along the Y-axis.

Parameters:
y - specifies how much this object will be moved
isLocal - specifies whether the object is moved along its local axes or along the axes of scene

translateZ

public void translateZ(float z,
                       boolean isLocal)
Moves the object along the Z-axis.

Parameters:
z - specifies how much this object will be moved
isLocal - specifies whether the object is moved along its local axes or along the axes of scene

translate

public void translate(float x,
                      float y,
                      float z)
Sets the given absolute translation on each axis.

Parameters:
x - absolute translation on X-axis
y - absolute translation on Y-axis
z - absolute translation on Z-axis

getTranslationX

public float getTranslationX()
Returns the position on X-axis.

Returns:
Returns the position on X-axis

getTranslationY

public float getTranslationY()
Returns the position on Y-axis.

Returns:
Returns the position on Y-axis

getTranslationZ

public float getTranslationZ()
Returns the position on Z-axis.

Returns:
Returns the position on Z-axis

scaleX

public void scaleX(float difference,
                   boolean isLocal)
Resizes this object on X-axis.

Parameters:
difference - specifies how much the object will be resized
isLocal - has no effect yet

scaleY

public void scaleY(float difference,
                   boolean isLocal)
Resizes this object on Y-axis.

Parameters:
difference - specifies how much the object will be resized
isLocal - has no effect yet

scaleZ

public void scaleZ(float difference,
                   boolean isLocal)
Resizes this object on Z-axis.

Parameters:
difference - specifies how much the object will be resized
isLocal - has no effect yet

scaleAll

public void scaleAll(float difference)
Resizes this object on all axes.

Parameters:
difference - specifies how much the object will be resized

scale

public void scale(float x,
                  float y,
                  float z)
Sets the given absolute scale on each axis.

Parameters:
x - absolute scale on X-axis
y - absolute scale on Y-axis
z - absolute scale on Z-axis

getScaleX

public float getScaleX()
Returns the scale on X-axis.

Returns:
Returns the scale on X-axis

getScaleY

public float getScaleY()
Returns the scale on Y-axis.

Returns:
Returns the scale on Y-axis

getScaleZ

public float getScaleZ()
Returns the scale on Z-axis.

Returns:
Returns the scale on Z-axis

rotateX

public void rotateX(float angle,
                    boolean isLocal)
Rotates the object around the X-axis.

Parameters:
angle - specifies how much the angle will be changed
isLocal - specifies whether the object is rotated around its local axes or around the axes of scene

rotateY

public void rotateY(float angle,
                    boolean isLocal)
Rotates the object around the Y-axis.

Parameters:
angle - specifies how much the angle will be changed
isLocal - specifies whether the object is rotated around its local axes or around the axes of scene

rotateZ

public void rotateZ(float angle,
                    boolean isLocal)
Rotates the object around the Z-axis.

Parameters:
angle - specifies how much the angle will be changed
isLocal - specifies whether the object is rotated around its local axes or around the axes of scene

rotate

public void rotate(float x,
                   float y,
                   float z)
Sets the given absolute angle on each axis.

Parameters:
x - absolute angle around X-axis in degrees
y - absolute angle around Y-axis in degrees
z - absolute angle around Z-axis in degrees

getRotationX

public float getRotationX()
Returns the rotation around X-axis.

Returns:
Returns the rotation around X-axis in degrees

getRotationY

public float getRotationY()
Returns the rotation around Y-axis.

Returns:
Returns the rotation around Y-axis in degrees

getRotationZ

public float getRotationZ()
Returns the rotation around Z-axis.

Returns:
Returns the rotation around Z-axis in degrees